<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 18] Deflater</TITLE>
<META NAME="author" CONTENT="Mark Grand and Jonathan Knudsen">
<META NAME="date" CONTENT="Fri Aug  8 17:49:03 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java Fundamental Classes Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Fundamental Classes Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch18_06.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 18<br>The java.util.zip Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch18_08.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>Deflater</H1>

<H2>Name</H2>

Deflater

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch18-REFSECT1-AUTOID.40">Synopsis</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Class Name:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.util.zip.Deflater</tt>

<p>
<DT CLASS=varlistentry>Superclass:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.lang.Object</tt>

<p>
<DT CLASS=varlistentry>Immediate Subclasses:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Interfaces Implemented:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Availability:<br>
<DD>

<P CLASS=para>
New as of JDK 1.1 </DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch18-REFSECT1-AUTOID.41">Description</A></h2>

<P CLASS=para>
The <tt CLASS=literal>Deflater</tt> class provides 
support for general-purpose data compression. The class uses the ZLIB compression 
algorithms described in RFC 1950, RFC 1951, and RFC 1952. These documents 
can be found at: 
<P>
<UL CLASS=itemizedlist>
<li CLASS=listitem><I CLASS=emphasis>ftp://ds.internic.net/rfc/rfc1950.txt</I>

<P>
<li CLASS=listitem><I CLASS=emphasis>ftp://ds.internic.net/rfc/rfc1951.txt</I>

<P>
<li CLASS=listitem><I CLASS=emphasis>ftp://ds.internic.net/rfc/rfc1952.txt</I>

<P>
</UL>
<P CLASS=para>
The <tt CLASS=literal>Inflater</tt> class uncompresses 
data that has been compressed using <tt CLASS=literal>Deflater</tt>. 

<P CLASS=para>
The <tt CLASS=literal>DeflaterOutputStream</tt> uses 
an internal <tt CLASS=literal>Deflater</tt> to compress 
data. Typically, you do not need to create a <tt CLASS=literal>Deflater</tt>; 
instead, you can just use an instance of one of the subclasses of <tt CLASS=literal>DeflaterOutputStream</tt> : 
<tt CLASS=literal>GZIPOutputStream</tt> or <tt CLASS=literal>ZipOutputStream</tt>. 

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch18-REFSECT1-AUTOID.42">Class Summary</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public class java.util.zip.Deflater extends java.lang.Object {
  // Constants
  public static final int BEST_COMPRESSION;
  public static final int BEST_SPEED;
  public static final int DEFAULT_COMPRESSION;
  public static final int DEFAULT_STRATEGY;
  public static final int DEFLATED;
  public static final int FILTERED;
  public static final int HUFFMAN_ONLY;
  public static final int NO_COMPRESSION;
  // Constructors
  public Deflater();
  public Deflater(int level);
  public Deflater(int level, boolean nowrap);
  // Public Instance Methods
  public int deflate(byte[] b);
  public synchronized native int deflate(byte[] b, int off, int len);
  public synchronized native void end();
  public synchronized void finish();
  public synchronized boolean finished();
  public synchronized native int getAdler();
  public synchronized native int getTotalIn();
  public synchronized native int getTotalOut();
  public boolean needsInput();
  public synchronized native void reset();
  public void setDictionary(byte[] b);
  public synchronized native void setDictionary(byte[] b, int off, int len);
  public void setInput(byte[] b);
  public synchronized void setInput(byte[] b, int off, int len);
  public synchronized void setLevel(int level);
  public synchronized void setStrategy(int strategy);
  // Protected Instance Methods
  protected void finalize();
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch18-REFSECT1-AUTOID.43">Constants</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.20">BEST_COMPRESSION</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.28">public static final int BEST_COMPRESSION = 9</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant that represents a compression level that sacrifices speed for 
the smallest compressed data size. The compression level for a <tt CLASS=literal>Deflater</tt> 
object can be set with <tt CLASS=literal>setLevel()</tt>, 
where the level ranges from 0 to 9. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.21">BEST_SPEED</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.29">public static final int BEST_SPEED = 1</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant that represents a compression level that sacrifices compressed 
data size for speed. The compression level for a <tt CLASS=literal>Deflater</tt> 
object can be set with <tt CLASS=literal>setLevel()</tt>, 
where the level ranges from 0 to 9. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.22">DEFAULT_COMPRESSION</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.30">public static final int DEFAULT_COMPRESSION = -1</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant that represents the default compression level. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.23">DEFAULT_STRATEGY</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.31">public static final int DEFAULT_STRATEGY</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant that represents the default compression strategy. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.24">DEFLATED</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.32">public static final int DEFLATED</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant that represents a compression method that uses the deflate algorithm. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.25">FILTERED</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.33">public static final int FILTERED</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant that represents a compression strategy that works well for small 
values with a random distribution. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.26">HUFFMAN_ONLY</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.34">public static final int HUFFMAN_ONLY</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant that represents a compression strategy that uses only Huffman 
coding. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.27">NO_COMPRESSION</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.35">public static final int NO_COMPRESSION = 0</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
A constant that represents a compression level that does not compress data 
at all. The compression level for a <tt CLASS=literal>Deflater</tt> 
object can be set with <tt CLASS=literal>setLevel()</tt>, 
where the level ranges from 0 to 9. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch18-REFSECT1-AUTOID.44">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.28">Deflater</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.36">public Deflater()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>Deflater</tt> 
that generates compressed data in the ZLIB format using the <tt CLASS=literal>DEFAULT_COMPRESSION</tt> 
level. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.37">public Deflater(int level)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>level</tt><br>
<DD>

<P CLASS=para>
The compression level, 
from 0 (<tt CLASS=literal>NO_COMPRESSION</tt>) to 
9 (<tt CLASS=literal>BEST_COMPRESSION</tt>). </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>Deflater</tt> 
that generates compressed data in the ZLIB format using the given compression 
level. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.38">public Deflater(int level, boolean nowrap)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>level</tt><br>
<DD>

<P CLASS=para>
The compression level, 
from 0 (<tt CLASS=literal>NO_COMPRESSION</tt>) to 
9 (<tt CLASS=literal>BEST_COMPRESSION</tt>).

<p>
<DT CLASS=varlistentry><tt CLASS=literal>nowrap</tt><br>
<DD>

<P CLASS=para>
A <tt CLASS=literal>boolean</tt> 
value that specifies whether or not the ZLIB header and checksum data are 
omitted from the compressed data. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>Deflater</tt> 
that generates compressed data using the given compression level. If <tt CLASS=literal>nowrap</tt> 
is <tt CLASS=literal>true</tt>, the ZLIB header and 
checksum fields are not used, which means that the compressed data is in 
the format used by GZIP and PKZIP. If the parameter is <tt CLASS=literal>false</tt>, 
the data is compressed into ZLIB format. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch18-REFSECT1-AUTOID.45">Public Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.29">deflate</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.39">public int deflate(byte[] b)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>b</tt><br>
<DD>

<P CLASS=para>
A byte array to be filled. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The number of compressed bytes actually written to the array or 0 if more 
data may be required. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method compresses the data passed to <tt CLASS=literal>setInput()</tt> 
and fills the given array with the compressed data. If this method returns 
zero, <tt CLASS=literal>needsInput()</tt> should be called 
to determine whether the <tt CLASS=literal>Deflater</tt> 
needs more data in its input buffer. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.40">public synchronized native int deflate(byte[] b, int off, int len)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>b</tt><br>
<DD>

<P CLASS=para>
A byte array to be filled.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>off</tt><br>
<DD>

<P CLASS=para>
An offset into the byte array.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>len</tt><br>
<DD>

<P CLASS=para>
The number of bytes to fill. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The number of compressed bytes actually written to the array or 0 if more 
data may be required. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method compresses the data passed to <tt CLASS=literal>setInput()</tt> 
and writes <tt CLASS=literal>len</tt> bytes of the 
compressed data into the given array, starting at <tt CLASS=literal>off</tt>. 
If this method returns 0, <tt CLASS=literal>needsInput()</tt> 
should be called to determine whether the <tt CLASS=literal>Deflater</tt> 
needs more data in its input buffer. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.30">end</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.41">public synchronized native void end()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method discards any uncompressed input data and frees up internal 
buffers. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.31">finish</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.42">public synchronized void finish()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method tells the <tt CLASS=literal>Deflater</tt> 
that the compression should end with the data that currently occupies the 
input buffer. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.32">finished</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.43">public synchronized boolean finished()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A <tt CLASS=literal>boolean</tt> value that indicates 
whether or not the end of the compressed data has been reached. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns <tt CLASS=literal>true</tt> if 
the last of the compressed data has been read using <tt CLASS=literal>deflate()</tt>. 
Otherwise it returns <tt CLASS=literal>false</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.33">getAdler</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.44">public synchronized native int getAdler()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The Adler-32 checksum value of the uncompressed data. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns an Adler32 checksum value that is calculated on the 
uncompressed data passed to <tt CLASS=literal>setInput()</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.34">getTotalIn</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.45">public synchronized native int getTotalIn()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The total number of bytes that have been input so far. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the number of bytes that have been passed to <tt CLASS=literal>setInput()</tt> 
since this <tt CLASS=literal>Deflater</tt> was created 
or since <tt CLASS=literal>reset()</tt>was last called. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.35">getTotalOut</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.46">public synchronized native int getTotalOut()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The total number of bytes that have been output so far. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the number of bytes that have been read from <tt CLASS=literal>deflate()</tt> 
since this <tt CLASS=literal>Deflater</tt> was created, 
or since <tt CLASS=literal>reset()</tt> was last called. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.36">needsInput</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.47">public boolean needsInput()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A <tt CLASS=literal>boolean</tt> value that indicates 
whether or not the input buffer is empty. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns <tt CLASS=literal>true</tt> if 
the input buffer is empty. Otherwise it returns <tt CLASS=literal>false</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.37">reset</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.48">public synchronized native void reset()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method resets the <tt CLASS=literal>Deflater</tt> 
to the state it was in when it was created, which means that a new set 
of data can be compressed. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.38">setDictionary</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.49">public void setDictionary(byte[] b)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>b</tt><br>
<DD>

<P CLASS=para>
An array of byte values. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method sets the preset dictionary for compression using the data in 
the given array. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.50"><DIV CLASS=screen> <P> <PRE> public synchronized native void setDictionary(byte[] b, int off, int len) </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>b</tt><br>
<DD>

<P CLASS=para>
An array of byte values.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>off</tt><br>
<DD>

<P CLASS=para>
An offset into the byte array.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>len</tt><br>
<DD>

<P CLASS=para>
The number of bytes to use. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method sets the preset dictionary for compression using <tt CLASS=literal>len</tt> 
bytes from the given array, starting from <tt CLASS=literal>off</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.39">setInput</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.51">public void setInput(byte[] b)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>b</tt><br>
<DD>

<P CLASS=para>
An array of byte values. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method places the contents of the given array into the input buffer 
of this <tt CLASS=literal>Deflater</tt>. Use the <tt CLASS=literal>deflate()</tt> 
method to compress the data and retrieve it in compressed form. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.52">public synchronized void setInput(byte[] b, int off, int len)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>b</tt><br>
<DD>

<P CLASS=para>
An array of byte values.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>off</tt><br>
<DD>

<P CLASS=para>
An offset into the byte array.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>len</tt><br>
<DD>

<P CLASS=para>
The number of bytes to use. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method places <tt CLASS=literal>len</tt> bytes 
from the given array, starting at <tt CLASS=literal>off</tt>, 
into the input buffer of this <tt CLASS=literal>Deflater</tt>. 
Use the <tt CLASS=literal>deflate()</tt> method to 
compress the data and retrieve it in compressed form. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.40">setLevel</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.53">public synchronized void setLevel(int level)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>level</tt><br>
<DD>

<P CLASS=para>
The compression level, 
from 0 (<tt CLASS=literal>NO_COMPRESSION</tt>) to 
9 (<tt CLASS=literal>BEST_COMPRESSION</tt>). </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IllegalArgumentException</tt><br>
<DD>

<P CLASS=para>
If <tt CLASS=literal>level</tt> is not valid. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method sets the compression level of this <tt CLASS=literal>Deflater</tt>. 
A value of 0 corresponds to <tt CLASS=literal>NO_COMPRESSION</tt>. 
A value of 1 indicates the fastest, least space-efficient compression level 
(<tt CLASS=literal>BEST_SPEED</tt>). A value of 9 
indicates the slowest, most space-efficient compression level (<tt CLASS=literal>BEST_COMPRESSION</tt>). </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.41">setStrategy</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.54">public synchronized void setStrategy(int strategy)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>strategy</tt><br>
<DD>

<P CLASS=para>
The compression strategy. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IllegalArgumentException</tt><br>
<DD>

<P CLASS=para>
If <tt CLASS=literal>strategy</tt> is not valid. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method sets the compression strategy of this <tt CLASS=literal>Deflater</tt>, 
which should be one of <tt CLASS=literal>FILTERED</tt>, 
<tt CLASS=literal>HUFFMAN_ONLY</tt>, or <tt CLASS=literal>DEFAULT_STRATEGY</tt>. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch18-REFSECT1-AUTOID.46">Protected Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch18-REFSECT2-AUTOID.42">finalize</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch18-REFSECT3-AUTOID.55">protected void finalize()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.finalize()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method calls <tt CLASS=literal>end()</tt> when 
this <tt CLASS=literal>Deflater</tt> is garbage collected. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch18-REFSECT1-AUTOID.47">Inherited Methods</A></h2>

<DIV CLASS=informaltable>
<P>
<TABLE CLASS=INFORMALTABLE>
<TR CLASS=row>
<TH ALIGN="LEFT">

<P CLASS=para>
Method</TH>
<TH ALIGN="LEFT">

<P CLASS=para>
Inherited From</TH>
<TH ALIGN="LEFT">

<P CLASS=para>
Method</TH>
<TH ALIGN="LEFT">

<P CLASS=para>
Inherited From</TH>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>clone()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>equals(Object)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>getClass()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>hashCode()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>notify()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>notifyAll()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>toString()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>wait()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>wait(long)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>wait(long, 
int)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
</TABLE>
<P>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch18-REFSECT1-AUTOID.48">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>DeflaterOutputStream</tt>, 
<tt CLASS=literal>Inflater</tt>, 
<tt CLASS=literal>GZIPOutputStream</tt>, 
<tt CLASS=literal>ZipOutputStream</tt> 
</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch18_06.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch18_08.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>DataFormatException</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>DeflaterOutputStream</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
